Ext.define('RDB.view.window.DisplayCustomers', {
    extend: 'Ext.window.Window',
    alias: 'widget.displaycustomers',
    title: 'Display Customers',
    height: 260,
	minHeight: 260,
	maxHeight: 260,
	width: 500,
	minWidth: 500,
	autoShow: true,
	layout: 'fit',
	tbar:[{
		xtype: 'button',
		text: 'Add',
		name: 'addcustomer'
	},{
		xtype: 'button',
		text: 'Remove',
		name: 'removecustomer'
	},'|',{
		xtype: 'button',
		text: 'Download XLS',
		name: 'download_xls'
	}],
	items: {
		xtype: 'grid',
		plugins: Ext.create('Ext.grid.plugin.RowEditing', {
	        listeners: {
	            cancelEdit: function(rowEditing, context) {
	                // Canceling editing of a locally added, unsaved record: remove it
	                if (context.record.phantom) {
	                    store.remove(context.record);
	                }
	            }
	        }
	    }),
		store: Ext.create('RDB.store.CustomersStore'),
		loadMask: true,
		columns: [{
			text: 'id',
			dataIndex: 'id',
			align: 'right',
			width: 30
		},{
			text: 'Customer name',
			dataIndex: 'name',
			align: 'left',
			width: 150,
			field: {
				xtype: 'textfield'
			}
		},{
			text: 'Customer group',
			dataIndex: 'group',
			align: 'left',
			flex: 1,
			field: {
				xtype: 'combo',
				store: Ext.create('RDB.store.CustomerGroupStore'),
				displayField: 'group',
				editable: false
			}
		}]
	}
});
